package com.tsc.design.strategyMode.example;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chentl
 * @Date: 2025/09/17/20:59
 * @Description:
 */
public class ShoppingCart {
    private PaymentStrategy paymentStrategy;

    public void setPaymentStrategy(PaymentStrategy paymentStrategy) {
        this.paymentStrategy = paymentStrategy;
    }
    public void pay(int amount) {
        if (paymentStrategy == null) {
            System.out.println("请设置支付方式");
            return;
        }
        paymentStrategy.pay(amount);
    }
}
